caboCity.implement({
	iniConnection: function(){
		this.socket = null;
		this.connected = false;
		
		this.connect();
	}
	,connect: function(){
		this.socket = io.connect('localhost', { port: 5556});

		this.socket.on('connect', function () {
			console.log("Estas conectado.");
		});
	
		this.socket.on('command', (function (c) {
			console.log("Nuevo comando.");
			
			var answer = this.executeCommand(c);
			this.sendAnswer(answer);
			
		}).bind(this));
	
		this.socket.on('answer', (function (a) {
			console.log("Nueva respuesta.");
			this.processAnswer(a);
		}).bind(this) );
		
		this.socket.on('disconnect', function(){
			console.log("Desconectado.");
		});
	}
	,sendAnswer: function(answer){
		this.socket.emit('answer', answer);
	}
	,sendCommand: function(command){
		this.socket.emit('command', command);
	}
});
